package com.ldatum.crm.serviceImpl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.ldatum.crm.daoImpl.TServicesDaoImpl;
import com.ldatum.crm.domain.TServices;
import com.ldatum.crm.service.TServicesDao;
import com.ldatum.crm.service.TServicesService;

public class TServicesServiceImpl implements TServicesService {

	TServicesDao servicesDao = new TServicesDaoImpl();
	
	@Override
	public TServices findById(int id) throws Exception{
		return servicesDao.findById(id);
	}

	@Override
	public void save(TServices servicesBill) throws Exception{
		servicesDao.save(servicesBill);
	}

	@Override
	public List<TServices> list(Class<TServices> class1, String session) throws Exception{
		return servicesDao.list(class1,session);
	}

	@Override
	public List<TServices> listByMe(Class<TServices> class1, String creater)
			throws Exception {
		return servicesDao.listByMe(class1, creater);
	}

	@Override
	public List<TServices> listToMe(Class<TServices> class1, String creater)
			throws Exception {
		return servicesDao.listToMe(class1, creater);
	}

	@Override
	public void update(TServices service) throws Exception {
		if("完成".equals(service.getStatus()) && "".equals(service.getFinishTime())){
			service.setFinishTime(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
		}
		servicesDao.update(service);
	}
}
